package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.OutDrugBean;
import com.project.bean.OutWareHouseBean;
import com.project.dao.IWareHouseDao;
import com.project.service.IWareHouseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.Collection;
import java.util.Map;

/**
 * @author RJ
 * @date 2022/9/15 19:53
 */
@Service
@Transactional
public class WareHouseServiceImpl extends ServiceImpl<IWareHouseDao, OutWareHouseBean> implements IWareHouseService {

    @Override
    public void addWareHouse(OutWareHouseBean outWareHouseBean, Map<Integer, OutDrugBean> map) {
        this.baseMapper.addWareHouse(outWareHouseBean);
        Collection<OutDrugBean> list = map.values();
        this.baseMapper.addInfo(list, outWareHouseBean.getOutId());
    }

    @Override
    public OutWareHouseBean getOutInfo(Integer outId) {
        return this.baseMapper.getOutInfo(outId);
    }

    @Override
    public IPage<OutWareHouseBean> cutOutByItem(Integer pageNo, Integer pageSize, LocalDate startDate, LocalDate endDate, String outUser) {
        Page<OutWareHouseBean> page = new Page<>(pageNo, pageSize);
        IPage<OutWareHouseBean> iPage = this.baseMapper.cutOutByItem(page, startDate, endDate, outUser);
        return iPage;
    }
}
